#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

class Solution
{
public:
    int singleNumber(vector<int> &nums)
    {
        int cache=0;
        for (auto num : nums)
        {
            cache ^= num;
        }
        return cache;
    }
    int singleNumber_1(vector<int> &nums)
    {
        bitset<60001> bitMap(0);
        for (auto num : nums)
        {
            bitMap[num + 30000] = !bitMap[num + 30000];
        }
        for (int i = 0; i < 60001; i++)
        {
            if (bitMap[i] != 0)
            {
                return i - 30000;
            }
        }
        return 0;
    }
};

int main()
{
    vector<int> nums = {2, 2, 1};
    Solution s;
    cout << s.singleNumber(nums) << endl;
    return 0;
}